#!/usr/bin/python
#coding:utf8
'''
Adapter
'''
class Adapter:
    """
    Adapts an object by replacing methods.

    """
    def __init__(self, obj, adapted_methods):
        """We set the adapted methods in the object's dict"""
        self.obj = obj
        self.__dict__.update(adapted_methods)
    
    def __getattr__(self, attr):
        """All non-adapted calls are passed to the object"""
        return getattr(self.obj, attr)

class Dog:
    def __init__(self):
        self.name = "Dog"

    def wang(self):
        return "wangwang!"

class Cat:
    def __init__(self):
        self.name = "Cat"

    def miao(self):
        return "miaomiao!"

if __name__ == "__main__":
    dog = Dog()
    dog = Adapter(dog, dict(make_noise=dog.wang))
    cat = Cat()
    cat = Adapter(cat, dict(make_noise=cat.miao))
    print(f"{dog.name} makes {dog.make_noise()}")
    print(f"{cat.name} makes {cat.make_noise()}")
    
